package com.zhx.learn.learn.controller;

import com.zhx.learn.learn.dao.UserDao;
import com.zhx.learn.learn.test.TestConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * describe:
 *
 * @author zhanghaixuan
 * @date 2018/09/13
 **/
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserDao userDao;

    @Autowired
    private TestConfig testConfig;

    @GetMapping("/{id}")
    public ResponseEntity getById(@PathVariable Integer id){
        return ResponseEntity.ok(userDao.findById(id));
    }

    @GetMapping("/list")
    public ResponseEntity list(){
        return ResponseEntity.ok(userDao.findAll());
    }


    @GetMapping("/test")
    public String test(){
        log.info(testConfig.toString());
        return testConfig.getTest();
    }
}
